#! c:\\Perl\\bin\\perl.exe w

use strict;
use ADN::LIBRARY::SNMP::Liens;
use ADN::LIBRARY::SOAP::ClientSOAP;
use ADN::XML::OBJtoXML;

my $ip = $ARGV[0];
my $Srep = $ARGV[1];
my $param = $ARGV[2];

main();
exit 0;

sub main {

  my ( $liens, $nbr, $xml, $result );
  my ( @tab, @prm, @data, @result );

  @tab = split /\%\!\%\*\%\~\%/smx, $param;
  $nbr = scalar @tab;
  print "NBR : $nbr\n";

  for ( my $i = 0; $i < $nbr; $i++ ) {
    @prm = split /\@\#\@\*\@\~\@/smx, $tab[$i];
  }

  $nbr = scalar @prm;
  print "NBR PRM : $nbr\n";

  if ($nbr != 2) {
    print 'Erreur ARG !!!';
    exit 0;
  }

  print "Arg: $prm[0] ET $prm[1]";

  @data = split /;/smx, $prm[0];

  $liens = ADN::LIBRARY::SNMP::Liens->new();
  $result = $liens->start(@data);

  $xml = ADN::XML::OBJtoXML->new();
  $xml->Name($prm[1]);
  $xml->Map($xml);
  $xml->Data($result);
  $xml->Liens($xml);
  $xml->Listeip($prm[0]);
  @result = $xml->Return($xml);

  print "\nDATA : ";
  print @result;

  ADN::LIBRARY::SOAP::ClientSOAP->new( Proxy => $ip,
						                           Service => $Srep,
						                           Data => \@result );
  return;
}
